<?php

$lib_dir = 'nrg';

if ( isset($_GET['lib_dir']) ) {
	$lib_dir = $_GET['lib_dir'];
}

$js_lib_path = APP_PATH . "/../public/js/lib";

set_include_path( $js_lib_path . PATH_SEPARATOR . get_include_path() );

function diList(DirectoryIterator $Di)
{
	foreach ( $Di as $File ) {
		
		$pathinfo = pathinfo( $File->getPathname() );
		
		if ( $File->isDir() && ! $File->isDot() ) {
			diList( new DirectoryIterator( $File->getPathname() ) );
		}
		else if ( isset($pathinfo['extension']) && 'js' == $pathinfo['extension'] ) {
			//echo "\n\n" . file_get_contents( $File->getPathname() );
			require_once $File->getPathname();
		}
	}
}

diList( new DirectoryIterator("{$js_lib_path}/{$lib_dir}") );